cmake_minimum_required(VERSION 3.13)
project(lua LANGUAGES C VERSION 5.4.4)

set(src_code
    src/lapi.c
    src/lcode.c
    src/lctype.c
    src/ldebug.c
    src/ldo.c
    src/ldump.c
    src/lfunc.c
    src/lgc.c
    src/llex.c
    src/lmem.c
    src/lobject.c
    src/lopcodes.c
    src/lparser.c
    src/lstate.c
    src/lstring.c
    src/ltable.c
    src/ltm.c
    src/lundump.c
    src/lvm.c
    src/lzio.c
)

set(src_lib
    src/lauxlib.c
    src/lbaselib.c
    src/lcorolib.c
    src/ldblib.c
    src/liolib.c
    src/lmathlib.c
    src/loadlib.c
    src/loslib.c
    src/lstrlib.c
    src/ltablib.c
    src/lutf8lib.c
    src/linit.c
)

set(src_exec src/lua.c)
set(src_comp src/luac.c)

include_directories(include/lua)

# add_library(liblua_static STATIC ${src_code} ${src_lib})
# set_target_properties(liblua_static PROPERTIES OUTPUT_NAME lua)

add_library(lua SHARED ${src_code} ${src_lib})
set_target_properties(lua PROPERTIES INSTALL_RPATH "$ORIGIN")

# add_executable(lua ${src_code} ${src_lib} ${src_exec})
# set_target_properties(lua PROPERTIES OUTPUT_NAME lua)